//
//  TBRRentPersonMessageCell.m
//  TBText
//
//  Created by yy on 2018/4/30.
//  Copyright © 2018年 yy. All rights reserved.
//

#import "TBRRentPersonMessageCell.h"

@implementation TBRRentPersonMessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_tf_name addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventEditingChanged];
    [_tf_nameCall addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventEditingChanged];
    [_tf_phoneNum addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventEditingChanged];
}

- (void)setPersonInfoModel:(TBRRentPersonInfoModel *)personInfoModel {
    _personInfoModel = personInfoModel;
    _tf_name.text = [NSString stringWithFormat:@"%@",[HelpObject changeNull:personInfoModel.personName]];
    _tf_nameCall.text = [NSString stringWithFormat:@"%@",[HelpObject changeNull:personInfoModel.personNameCall]];
    _tf_phoneNum.text = [NSString stringWithFormat:@"%@",[HelpObject changeNull:personInfoModel.phoneNum]];
}

- (IBAction)addressBookBtnClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(personMessageCellAddressBookBtnClick)]) {
        [self.delegate personMessageCellAddressBookBtnClick];
    }
}


- (void)valueChange:(UITextField *)tf {
    if (tf == _tf_name) {
        self.personInfoModel.personName = tf.text;
    }else if (tf == _tf_nameCall) {
        self.personInfoModel.personNameCall = tf.text;
    }else if (tf == _tf_phoneNum) {
        self.personInfoModel.phoneNum = tf.text;
    }
}

@end
